{% extends 'base.html' %}

{% block title %}{% if category %}编辑资产类别{% else %}新增资产类别{% endif %} - 固定资产管理系统{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-6">
        <h2>{% if category %}编辑资产类别{% else %}新增资产类别{% endif %}</h2>
        
        <form method="post">
            {% csrf_token %}
            
            <div class="mb-3">
                <label for="name" class="form-label">类别名称 *</label>
                <input type="text" class="form-control" id="name" name="name" value="{% if category %}{{ category.name }}{% else %}{{ name|default:'' }}{% endif %}" required>
            </div>
            
            <div class="mb-3">
                <label for="code" class="form-label">类别代码 *</label>
                <input type="text" class="form-control" id="code" name="code" value="{% if category %}{{ category.code }}{% else %}{{ code|default:'' }}{% endif %}" required>
            </div>
            
            <div class="mb-3">
                <label for="description" class="form-label">描述</label>
                <textarea class="form-control" id="description" name="description" rows="3">{% if category %}{{ category.description }}{% else %}{{ description|default:'' }}{% endif %}</textarea>
            </div>
            
            <div class="mb-3">
                <button type="submit" class="btn btn-primary">{% if category %}更新{% else %}创建{% endif %}</button>
                <a href="{% url 'assets:category_list' %}" class="btn btn-secondary">取消</a>
            </div>
        </form>
    </div>
</div>
{% endblock %}